package biz

import "github.com/golang-jwt/jwt/v4"

// @secret string : JWT secret key
// @iat int64 : timestamp
// @seconds int64 : expiration time in seconds
// @payload any : payload to be encoded in the token
func GetJwtToken(secret string, iat, seconds int64, payload map[string]any) (string, error) {
	claims := make(jwt.MapClaims)
	claims["exp"] = iat + seconds
	claims["iat"] = iat
	for key, value := range payload {
		claims[key] = value
	}
	token := jwt.New(jwt.SigningMethodHS256)
	token.Claims = claims
	return token.SignedString([]byte(secret))
}
